from django.core.serializers import serialize
from django.shortcuts import render
from rest_framework.response import Response
from rest_framework.views import APIView

from course import models, serializer


# Create your views here.
class HomeCate(APIView):
    def get(self,request):
        res=models.Course.objects.filter(parent=None,flag=True).order_by("order")
        ser = serializer.CourseSerializer(res, many=True)
        for item in ser.data:
            item["children"]= item["children"][:3]
        return Response({"code":200,"msg":"ok","data":ser.data})
class HomeChildren(APIView):
    def get(self,request):
        # res=models.Course.objects.filter(parent__isnull=False,flag=True).order_by("order")
        # ser = serializer.CourseSerializer(res, many=True)
        # return Response({"code":200,"msg":"ok","data":ser.data})
        pass









